package au.com.evoCoach.controller;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import au.com.evoCoach.domain.Coach;
import au.com.evoCoach.domain.League;
import au.com.evoCoach.form.ModifyPlayerForm;
import au.com.evoCoach.service.PlayerService;
import au.com.evoCoach.service.TeamService;

@Controller
public class ModifyPlayer{
	
	private TeamService teamService;
			
	@Autowired
	public ModifyPlayer(TeamService teamService) {
		this.teamService = teamService;
	}
	
	
	@RequestMapping(value = "/displayModifyPlayer.action") 
	public String displayAdmin(Map model, HttpSession session) {
		Coach coach = (Coach) session.getAttribute("loggedInCoach");
		League league = coach.getTeam().getLeague();
				
		model.put("teamDetailsList", teamService.getTeams(league));
		model.put("teamDetails", teamService.getTeamPlayersList(league));
		model.put("modifyPlayerForm", new ModifyPlayerForm());
		return "modifyPlayer";
	}
	
}